﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Traceability.App.Apilication.Common.Health;
using Traceability.Domain;
using Traceability.ErrorCode;

namespace Traceability.App.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class HealthController : ControllerBase
    {
        private readonly IMediator mediator;

        public HealthController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 添加保健信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> CreateHealthHandle(CreateHealthCommon request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 根据批次查询保健信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<List<HealthModel>>> GetHealthHandle([FromQuery]GetHealthCommon request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 保健信息修改方法
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public Task<ApiResult<int>> UpdateHealthHandle(UpdateHealthCommon request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 保健信息删除方法
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public Task<ApiResult<int>> DelHealthHandle(DelHealthCommon request)
        {
            return mediator.Send(request);
        }

        }
}
